﻿namespace Example
{
    using System;
    using System.Xml;

    using Cavity;

    using Xunit;

    public sealed class CavityExtensionMethodsFacts
    {
        [Fact]
        public void op_ToFileName_DateTime()
        {
            var date = new DateTime(1999, 1, 31, 8, 1, 5, 123);
            const string expected = "1999-01-31 08h01 05,123 GMT";
            var actual = date.ToFileName();

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void op_ToLocalTime_DateTime_TimeZoneInfo()
        {
            var obj = DateTime.UtcNow;

            var value = TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time");

            var expected = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(obj, value.Id);
            var actual = obj.ToLocalTime(value);

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void op_ToXmlString_object_whenDateTime()
        {
            var value = new DateTime(1999, 12, 31);

            Assert.Equal(XmlConvert.ToString(value, XmlDateTimeSerializationMode.Utc), value.ToXmlString());
        }
    }
}